package ui;

import java.util.Vector;

import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.StringItem;

import manager.AgentManagerMIDlet;


public class GetDestinationFinalScreen extends Form implements CommandListener{
    private final AgentManagerMIDlet midlet;
    //private final Form fmMain;
    //private final TextBox tbAction;
    private final Command exitCommand;
    private final Command myCommand1;
    private final Command myCommand2;
    private final Command confirmCommand;
//    private DateField timeEntry;
    private final Display display;
    private ChoiceGroup cgAgentFinal;
    private TextField tfNum;
    private Vector dests;
    private String message;
    private Vector startTimes;
    private Vector endTimes;
    private String type;

    GetDestinationFinalScreen(AgentManagerMIDlet midlet, String type, Display display,
    							Vector dests, Vector startTimes,Vector endTimes,
    							String message)
    {
        super("Are these numbers okay? ");
        this.type = type;
        this.display = display;
        this.midlet = midlet;
        this.dests = dests;
        this.message = message;
        this.startTimes = startTimes;
        this.endTimes = endTimes;
        
        for(int i = 0 ; i<dests.size();i++){
        //	System.out.println("Inside for loop Final Screen");
        	StringItem stringItem = new StringItem("Number " + (i+1) , (String)dests.elementAt(i));
        	this.append(stringItem);
        }
        
        myCommand1 = new Command("myCommand1", Command.SCREEN, 2);
        myCommand2 = new Command("myCommand2", Command.SCREEN, 3);
        confirmCommand = new Command("Confirm", Command.SCREEN,1);
        exitCommand = new Command("Exit", Command.EXIT, 1);

        this.addCommand(confirmCommand);
        this.addCommand(exitCommand);
        this.addCommand(myCommand1);
        this.addCommand(myCommand2);
        this.setCommandListener(this);
    }


    public void commandAction(Command c, Displayable d)
    {
        if (c == exitCommand)
        {
            midlet.exitRequested();
        }else if(c == confirmCommand){
        	midlet.getIOHandlerManager().createMeetingAgent(dests,type,startTimes,endTimes,message);
//        	GetConnectionTypeScreen connectionTypeScreen = new GetConnectionTypeScreen(midlet,
//        											display,
//        											dests,
//        											startTimes,
//        											endTimes,
//        											meetingLength);
        	//display.setCurrent(connectionTypeScreen);
        }
    }
}
